package org.example.demo.immutable;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.example.annotation.NotThreadSafe;

import java.util.Collections;
import java.util.Map;

@Slf4j
@NotThreadSafe
public class ImmutableExample1 {

    private final static Integer a = 1;
    private final static String b = "2";
    private final static Map<Integer, Integer> map = Maps.newHashMap();

    static {
        map.put(1, 2);
        map.put(3, 4);
        map.put(5, 6);
    }

    public static void main(String[] args) {
        //对于基本数据类型，final修饰将不能被修改
//        a = 2;
        //对于引用类型，在初始化后，不能指向另外一个对象
//        b = "3";
//        map = Maps.newHashMap();
        //对于引用类型，final修饰的是可以修改的，只是不能指向另外一个对象
        map.put(1, 3);
        log.info("{}", map.get(1));
    }

    private void test(final int a) {
//        a = 1;
    }
}
